﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MockPrjTeam2.DAO;
using System.Data;
using MockPrjTeam2.Entity;

namespace MockPrjTeam2.Biz
{
    public class TrustRegionBiz
    {
        private TrustRegionDao trustRegionDao;
        public TrustRegionBiz()
        {
            trustRegionDao = new TrustRegionDao();
        }
        
        public List<TrustRegion> GetAll()
        {
            return trustRegionDao.GetAll();
        }
        //method GetTrustRegionInActive()
        public DataTable GetInActive()
        {
            return trustRegionDao.GetInActive();
        }
        //method GetTrustRegionById()
        public TrustRegion GetById(int trustRegionId)
        {
            TrustRegion trustRegion = new TrustRegion();
            DataTable dt = new DataTable();
            dt = TrustRegionDao.Instance.GetById(trustRegionId);
            foreach (DataRow dr in dt.Rows)
            {

                trustRegion.TrustRegionName = dr["TrustRegionName"].ToString();
                trustRegion.Description = dr["Description"].ToString();
                trustRegion.CountryID = Convert.ToInt32(dr["CountryID"]);
                trustRegion.TrustRegionID = Convert.ToInt32(dr["TrustRegionID"]);
            }
            return trustRegion;
        }
        //method AddTrustRegion()
        public bool AddTrustRegion(TrustRegion trustRegion)
        {
            var newId = trustRegionDao.AddTrustRegion(trustRegion);
            return true;
        }
        //method UpdateTrustRegion()
        public bool UpdateTrustRegion(TrustRegion trustRegion)
        {
            return trustRegionDao.UpdateTrustRegion(trustRegion);
        }
        //Method SetActiveTrustRegion()
        public bool SetActive(int trustRegionId, bool status)
        {
            return trustRegionDao.SetActive(trustRegionId, status);
        }

        public bool SetInActive(int trustRegionId, bool status)
        {
            return trustRegionDao.SetInActive(trustRegionId, status);
        }
        
        public DataTable StartWithByNames(string startWith, int flag)
        {
            return trustRegionDao.StartWithByNames(startWith, flag);
        }
        //method CheckTrustRegionNameExist()
        public int CheckNameExist(string trustRegionName)
        {
            return trustRegionDao.CheckNameExist(trustRegionName);
        }
    }
}